﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DAL;
using Model;
using IDAL;
using BLL;

/***************************
 * 数据访问层
 * 部门数据
 * Author：JXL
 ***************************/ 
namespace EstateService.Controllers
{
    public class DepartmentController : ApiController
    {
        BLL.IFactory<IDepartmentDAL, DepartmentDAL> bll = new Factory<IDepartmentDAL, DepartmentDAL>();

        // GET api/department
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/department/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/department
        public void Post([FromBody]string value)
        {
        }

        // PUT api/department/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/department/5
        public void Delete(int id)
        {
        }

        [HttpGet]
        [ActionName("DeptShow")]
        public List<Department> DeptShow()
        {
            return bll.Fbi().DeptShow();
        }


        [HttpPost]
        [ActionName("DeptAdd")]
        public int DeptAdd(Department mo)
        {
            return bll.Fbi().DeptAdd(mo);
        }

        [HttpGet]
        [ActionName("DeptLike")]
        public List<Department> DeptLike(string name)
        {
            return bll.Fbi().DeptShow().Where(a => a.department_Name.Contains(name)).ToList();
        }


        [HttpGet]
        [ActionName("DeptCount")]
        public int DeptCount()
        {
            return bll.Fbi().DeptShow().Count();
        }
        [HttpPost]
        [ActionName("DeptFull")]
        public int DeptFull(int id)
        {
            return bll.Fbi().DeptFull(id);
        }


        [HttpPost]
        [ActionName("DeptStop")]
        public int DeptStop(int id)
        {
            return bll.Fbi().DeptStop(id);
        }

        [HttpGet]
        [ActionName("DeptSelectId")]
        public List<Department> DeptSelectId(int id)
        {
            return bll.Fbi().DeptSelectId(id);
        }

        [HttpPost]
        [ActionName("DeptDel")]
        public int DeptDel(int id)
        {
            return bll.Fbi().DeptDel(id);
        }
        [HttpPost]
        [ActionName("DeptUptFull")]
        public int DeptUptFull(Department mo)
        {
            if (bll.Fbi().DeptUptFull(mo) > 0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

    }
}
